#include <cstdlib>
#include <iostream>

// Coding in C/C++ without assertions is a scary thing
#define CHECK_HEADER __FILE__ << "(" << __LINE__ << "): "
#define CHECK(A) if (!(A)) { std::cerr << CHECK_HEADER << "Check " #A << " failed\n"; exit(1); }
#define CHECK_COMPARE(A,B,TEST) if (!((A) TEST (B))) { std::cerr << CHECK_HEADER << "Check " #A " " #TEST " " #B " failed\n"; exit(1); }
#define CHECK_LT(A,B) CHECK_COMPARE(A,B,<)
#define CHECK_LE(A,B) CHECK_COMPARE(A,B,<=)
#define CHECK_GT(A,B) CHECK_COMPARE(A,B,>)
#define CHECK_GE(A,B) CHECK_COMPARE(A,B,>=)
#define CHECK_EQ(A,B) CHECK_COMPARE(A,B,==)
#define CHECK_NE(A,B) CHECK_COMPARE(A,B,!=)
#define CHECK_NOTNULL(A) if ((A) == NULL) { std::cerr << CHECK_HEADER << "Check " #A " != NULL failed\n"; exit(1); }
